import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:lejiaxueche/provider/model.dart';
import 'package:provider/provider.dart';
import '../../../utils/methods.dart';
import '../../../config/colors.dart';

// 题目序号部件
class SubjectIndex extends StatelessWidget {
  final int index;

  SubjectIndex({
    this.index
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      alignment: Alignment.center,
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(26),
        color: Theme.of(context).primaryColor,
        border: Border.all(
          color: Theme.of(context).primaryColorLight
        )
      ),
      child: Text(
        '${index+1}', 
        style: TextStyle(
          fontSize: fitSize(30),
          color: Theme.of(context).primaryColorLight,
          decoration: TextDecoration.none,
          fontWeight: FontWeight.w400
        )
      ),
    );
  }
}

// 答题结果正确和错误数量统计
class AnswerResult extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Row(
      children: <Widget>[
        Row(
          children: <Widget>[
            Icon(
              Icons.check_circle,
              size: 16,
              color: Theme.of(context).accentColor,
            ),
            SizedBox(width: fitSize(6)),
            Consumer<SubLenModel>(
              builder: (context, slm, child) {
                return Text(
                  '${slm.rightNum}',
                  style: TextStyle(
                    fontSize: fitSize(28), 
                    color: Theme.of(context).accentColor,
                    decoration: TextDecoration.none,
                    fontWeight: FontWeight.w400
                  )
                );
              },
            )
          ],
        ),
        SizedBox(width: fitSize(50)),
        Row(
          children: <Widget>[
            Icon(
              Icons.remove_circle,
              size: 16,
              color: Theme.of(context).errorColor,
            ),
            SizedBox(width: fitSize(6)),
            Consumer<SubLenModel>(
              builder: (context, slm, child) {
                return Text(
                  '${slm.errorNum}',
                  style: TextStyle(
                    fontSize: fitSize(28), 
                    color: Theme.of(context).accentColor,
                    decoration: TextDecoration.none,
                    fontWeight: FontWeight.w400
                  )
                );
              },
            )
          ],
        )
      ],
    );
  }
}

// 试题详解
class QuestionSkill extends StatelessWidget {
  final Map content;

  QuestionSkill({
    this.content
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(
        top: fitSize(45)
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          Row(
            children: <Widget>[
              Container(
                width: fitSize(8),
                height: fitSize(26),
                decoration: BoxDecoration(
                  color: Color(AppColors.assistBlue),
                  borderRadius: BorderRadius.circular(2.0)
                ),
              ),
              SizedBox(width: fitSize(18)),
              Text('试题详解', style: TextStyle(fontSize: fitSize(28), color: Theme.of(context).primaryColorDark))
            ],
          ),
          SizedBox(height: fitSize(20)),
          Text(
            this.content['answer_explain'],
            style: TextStyle(
              height: 1.5,
              fontSize: fitSize(30),
              letterSpacing: 1.0,
              color: Theme.of(context).primaryColorDark
            )
          )
        ],
      ),
    );
  }
}